<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>${sessionScope.title}</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/admin/css/x-admin.css" media="all">
    <link rel="stylesheet" href="/js/layui/css/layui.css" media="all">
</head>
<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>域名设置</cite></a>
              <a><cite>域名管理</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">

    <xblock>
        <%--<button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon">&#xe640;</i>批量删除</button>--%>
        <button class="layui-btn" onclick="role_add('添加域名','/domain/add','1500','700')"><i class="layui-icon">&#xe608;</i>添加</button>
        <%--<span class="x-right" style="line-height:40px">共有数据：10000 条</span>--%>
    </xblock>
    <form class="layui-form" action="">
        <table class="layui-table">
            <thead>
            <tr>
                <th>域名</th>
                <th>类型</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${list}" var="l" >
                <tr>
                    <td>${l.domain}</td>
                    <c:choose>
                        <c:when test="${l.type==0}"><td>分享域名</td></c:when>
                        <c:otherwise><td>授权域名</td></c:otherwise>
                    </c:choose>
                    <c:choose>
                        <c:when test="${l.state==0}"><td>可用</td></c:when>
                        <c:otherwise><td>不可用</td></c:otherwise>
                    </c:choose>
                    <td class="td-manage">
                        <%--<a title="编辑" href="javascript:;" onclick="findRoleInfo('修改角色','/domain/update?rid=${l.id} ','1500','700')" class="layui-btn" >--%>
                            <%--编辑--%>
                        <%--</a>--%>
                        <a title="删除" href="javascript:;" onclick="role_del('${l.id} ')" class="layui-btn layui-btn-danger">
                            删除
                        </a>
                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </form>
    <div id="page"></div>
</div>
<script src="/js/layui/layui.all.js" charset="utf-8"></script>
<script src="/admin/js/x-layui.js" charset="utf-8"></script>
<script src="/admin/js/jquery.min.js" charset="utf-8"></script>
<script>








    layui.use(['laydate','element','laypage','layer'], function(){
        $ = layui.jquery;//jquery
        laydate = layui.laydate;//日期插件
        layer = layui.layer;//弹出层
        //以上模块根据需要引入
    });

    //批量删除提交
    function delAll () {
        layer.confirm('确认要删除吗？',function(index){
            //捉到所有被选中的，发异步进行删除
            layer.msg('删除成功', {icon: 1});
        });
    }
    /*添加*/
    function role_add(title,url,w,h){
        x_admin_show(title,url,w,h);
    }

    //编辑
    function findRoleInfo (title,url,w,h) {
        x_admin_show(title,url,w,h);
    }
    /*删除*/
    function role_del(id){
        layer.confirm("确定删除吗？",function(){
            $.ajax({
                url:'/domain/delete',
                type:'POST',
                data:{
                    rid:id
                },
                success:function(data){
                    if(data.data=='success'){
                        layer.msg('删除成功');
                        setTimeout(function(){
                            location.reload();
                        },1000);
                    }else {
                        layer.msg('删除失败，请稍候再试');
                    }
                }
            });
        })
    }
</script>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;"></fieldset>
<div id="fenye" style="text-align: center" ></div>

</body>
</html>
